package com.example.reagent_management.ui.statistics.helper;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

public class StateFragmentAdapter extends FragmentStateAdapter {

    private final List<Fragment> fragments;

    public StateFragmentAdapter(@NonNull Fragment fragment,@NonNull List<Fragment> fragments) {
        super(fragment);
        this.fragments = fragments;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }

    /*对于动态增删fragment具体情况实现重写*/
    @Override
    public boolean containsItem(long itemId) {
        return super.containsItem(itemId);
    }

    @Override
    public long getItemId(int position) {
        return super.getItemId(position);
    }
}
